-
-
Notifications
You must be signed in to change notification settings - Fork 441
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FreeBSD: scale CPU% usage on swap time #606
base: main
Are you sure you want to change the base?
Conversation
if (sysctlbyname("kern.ccpu", &ccpu, &size, NULL, 0) == -1) { | ||
ccpu = 0; | ||
} | ||
const double decayfactor = log(ccpu / kernelFScale); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
kernelFScale
might be zero. Not ensured non-zero by the code querying this from the syscall.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
htop/freebsd/FreeBSDProcessList.c
Lines 138 to 142 in feec16c
len = sizeof(kernelFScale); | |
if (sysctlbyname("kern.fscale", &kernelFScale, &len, NULL, 0) == -1) { | |
//sane default for kernel provided CPU percentage scaling, at least on x86 machines, in case this sysctl call failed | |
kernelFScale = 2048; | |
} |
You mean kern.fscale
might be 0
? Is that possible?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Highly unlikely, given that there's other code already that does a similar division and I'm not aware of any bug reports regarding this. Mostly DiD note.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually just looking at the remarked upon code part: ccpu
is set to 0
, which will cause a math error with the following calculation for decayfactor
. I don't think that's right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've made pull request #1275 that would reject zero kern.fscale
value.
See https://forums.freebsd.org/threads/how-does-cpu-utilization-is-calculates.12108/
and https://ess.cs.tu-dortmund.de/lockdoc-elixir/freebsd-lockdoc/lockdoc-v13.0-0.6/source/bin/ps/print.c#L650
Closes: #602